package com.itheima.neibulei6;

public class Test {
    public static void main(String[] args) {
        //Inter inter = new Inter();
        /*//使用局部内部类 实现接口
        class InterImpl implements Inter{
            @Override
            public void sing() {
                System.out.println("大碗宽面");
            }
        }
        InterImpl inter = new InterImpl();
        inter.sing();*/
        // 匿名内部类  实现接口 重写方法  创建对象
        //核心  多态
        Inter inter = new Inter() {
            @Override
            public void sing() {
                System.out.println("sing");
            }
        };
        inter.sing();

        Animal animal = new Animal() {
            @Override
            public void eat() {
                System.out.println("动物吃东西");
            }
        };
        animal.drink();
        animal.eat();
        Fu fu = new Fu(){
            @Override
            public void dance() {
                System.out.println("爱谁谁谁的dance");
            }
        };
        fu.dance();

        new Inter() {
            @Override
            public void sing() {
                System.out.println("只因你太美");
            }
        }.sing();
    }
}

interface Inter{
    void sing();
}
/*
class InterImpl implements Inter{

    @Override
    public void sing() {
        System.out.println("只因你太美");
    }
}*/
abstract class Animal{
    public void drink(){
        System.out.println("动物喝水");
    }
    public abstract void eat();
}
class Fu{
    public void dance(){
        System.out.println("父类的dance");
    }
}